from flask import Blueprint, render_template, request, flash, redirect, url_for, current_app, jsonify
from flask_login import login_required
from app.models.orders import Orders
from app.models.bills import Bills

bp = Blueprint('bills', __name__)


@bp.before_request
@login_required
def before_request():
    pass


@bp.route('/')
def index():
    page = request.args.get('page', 1, type=int)

    query = Bills.query.order_by(Bills.id.desc())

    pre_page = current_app.config['POST_PRE_PAGE']
    pagination = query.paginate(page, pre_page)
    return render_template('admin/bills/index.html',
                           model=pagination.items,
                           page=page,
                           pagination=pagination)

